package tech.mhuang.pacebox.core.exception;

/**
 * 业务通用异常
 *
 * @author mhuang
 * @since 1.0.0
 */
public class BusinessException extends RuntimeException {

    private static final long serialVersionUID = 1L;

    /**
     * 错误码
     */
    private int code;

    /**
     * 返回信息
     */
    private String message;

    /**
     * 字段名
     */
    private String field;
    /**
     * 异常
     */
    private Throwable cause;

    public BusinessException(int code, String message) {
        super(message);
        this.code = code;
        this.message = message;
    }

    public BusinessException(int code, String message,String field) {
        super(message);
        this.code = code;
        this.message = message;
        this.field = field;
    }


    public BusinessException(int code,String message,String field,Throwable cause){
        super(message, cause);
        this.code = code;
        this.message = message;
        this.field = field;
        this.cause = cause;
    }

    public BusinessException(int code,String message,String field,Throwable cause,boolean enableSuppression, boolean writableStackTrace){
        super(message, cause,enableSuppression,writableStackTrace);
        this.code = code;
        this.message = message;
        this.field = field;
        this.cause = cause;
    }


    public BusinessException(int code, String message, Throwable cause) {
        super(message, cause);
        this.code = code;
        this.message = message;
        this.cause = cause;
    }
    public BusinessException(int code, String message, Throwable cause,boolean enableSuppression, boolean writableStackTrace) {
        super(message, cause,enableSuppression,writableStackTrace);
        this.code = code;
        this.message = message;
        this.cause = cause;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    @Override
    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getField() {
        return field;
    }

    public void setField(String field) {
        this.field = field;
    }

    @Override
    public Throwable getCause() {
        return cause;
    }

    public void setCause(Throwable cause) {
        this.cause = cause;
    }
}
